#include <stdio.h>
#include <vector>
#include <algorithm>

int main() {
  int n;
  scanf("%d", &n);
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  std::sort(a.begin(), a.end());
  int sum1 = 0, sum2 = 0;
  for (int i = 0; i < n / 2; i++)
    sum1 += a[i];
  for (int i = n / 2; i < n; i++)
    sum2 += a[i];
  printf("%d\n", sum2 - sum1);
}
